#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Yunchao Ling'

import sys

infile = open(sys.argv[1], "r")
# outfile=open(sys.argv[1]+".deepmaxlength","w")

namelist={}
maxvalue={}

for line in infile:
    line = line.rstrip()
    if not line.startswith("##"):
        if line.startswith("#"):
            titleline = line[1:].split("\t")
            for i in range(len(titleline)):
                maxvalue[titleline[i]]=0
                namelist[i]=titleline[i]
        else:
            infoindex=-1
            for key in namelist.keys():
                if namelist[key]=="INFO":
                    infoindex=key
            splitline=line.split("\t")
            for i in range(len(splitline)):
                length=len(splitline[i])
                if length>maxvalue[namelist[i]]:
                    maxvalue[namelist[i]]=length
            if infoindex!=-1:
                infoline=splitline[infoindex]
                if not infoline==".":
                    splitinfoline=infoline.split(";")
                    for item in splitinfoline:
                        splititem=item.split("=")
                        name=splititem[0]
                        value=splititem[1]
                        length=len(value)
                        if maxvalue.has_key("name"):
                            if length>maxvalue[name]:
                                maxvalue[name]=length
                        else:
                            maxvalue[name]=length
print namelist
print titleline
print maxvalue
infile.close()
# outfile.close()
